<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<html:html>
<head>
<META http-equiv=Pragma content=no-cache>
<META http-equiv=Cache-Control content=no-cache>
<META http-equiv=Expires content=0>
<title><bean:message key="F0301.title"/></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet"
		href="<%=request.getContextPath()%>/resource/css/style.css"
		type="text/css">
	<script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/resource/js/util.js"></script>
	<script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/style/scripts/util.js"></script>
	<script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/resource/js/AdyhUtil.js"></script>
	<script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/resource/js/Validator.js"></script>	
	<script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/resource/calendar/DCDA_C03.js"></script>
	<script type="text/javascript"
		src="<%=request.getContextPath()%>/style/ext/adapter/ext/ext-base.js"></script>
	<script type="text/javascript"
		src="<%=request.getContextPath()%>/style/ext/ext-all.js"></script>	
<script language="javascript1.2">

function operation1(){
	if(validateActionForm(document.forms[0])){
			if(document.forms[0].layOutType.value=="add"){
	           operation('insert');
	       }else{
	           operation('update');
	       }	   
	}
}

function judge(){
	var quantity = document.forms[0].quantity.value;
	var groupQty = document.forms[0].groupQty.value;
	var allQty = document.forms[0].allQty.value;
	var groupQtyOther = document.forms[0].groupQtyOther.value;
	if(parseInt(quantity)<(parseInt(allQty)-parseInt(groupQtyOther)+parseInt(groupQty))){
	    
		alert("<bean:message key="F0301.quantityError"/>");
		document.forms[0].groupQty.value = groupQtyOther;
	}
	
}

function initDate(){
  		
  		var manufacturingOrder = document.getElementById("manufacturingOrder").value;     
  		var finishDate = document.getElementById("finishDate").value; 	      
   		Ext.Ajax.request(
   		{
		url : 'F0301.do' , 
		params : {operationType:'ajax',id:'beginDate',manufacturingOrder:manufacturingOrder,finishDate:finishDate},
		method: 'POST',
		success: function ( result, request) 
			{
			var reValue = "";
			reValue = result.responseText;
			document.forms[0].startDate.value = reValue; 
   			
			},	
		failure: function ( result, request){ 
			alert("<bean:message key="F020106.title"/>");
			} 
		}
		);
  }
  
function ShowFormTitle(strTitle){
	document.write("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"height:26px; background-position: left bottom; background-image: url(../../style/images/FormTitle_A_4.gif); background-repeat: repeat-x;\">");
	document.write("  <tr >");
	document.write("	<td style=\"width:5px; background-position: left bottom; background-image: url(../../style/images/FormTitle_A_1.gif); background-repeat: no-repeat;\">&nbsp;&nbsp;&nbsp;</td>");
	document.write("	<td class=\"FormTitle\" style=\"width:100%; padding-left:5px; padding-top:3px; background-position: left bottom; background-image: url(../../style/images/FormTitle_A_2.gif); background-repeat: no-repeat;\">");
	document.write("		<span id=\"spanFormTitle\" class=\"SpanTitle\">"+ strTitle +"</span>");
	document.write("	</td>");
	document.write("	<td style=\"width:5px; background-position: right bottom; background-image: url(../../style/images/FormTitle_A_3.gif); background-repeat: no-repeat;\">&nbsp;&nbsp;&nbsp;</td>");
    document.write("  </tr>");
	document.write("</table>");
}	

</script>
</head>

<body marginheight="0" marginwidth="0" bottommargin="0" topmargin="0" >
<html:form method="post" action="/pages/F03/F0301.do" enctype="multipart/form-data">
<html:hidden property="operationType"/>
<html:hidden property="layOutType" />
<html:hidden property="ID" />
<html:hidden property="allQty" />
<html:hidden property="groupQtyOther" />
<!--Begin：表单标题-->
<div class="DivBlock">
	<script language="javascript" type="text/javascript">
		ShowFormTitle("<bean:message key="F0301.title"/>");
	</script>
</div>
<!--End：表单标题-->
<!--Begin：表单折叠区块1-->
<div class="DivBlock">
<div class="DivWrap">
  <table  WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
	<tr>	
		<td align="center"><bean:message key="common.ManufacturingOrder"/></td>
		<td><html:text property="manufacturingOrder" styleClass="MyTextReadOnly" readonly="true"/></td>
		<td  align="center"><bean:message key="adyh.familyCode"/></td>
		<td><html:text property="familyCode" styleClass="MyTextReadOnly" readonly="true"/></td>		
		<td align="center"><bean:message key="adyh.model"/></td>
		<td><html:text property="model" styleClass="MyTextReadOnly" readonly="true"/>
		</td>		
	</tr>
	<tr>
		<td align="center"><bean:message key="adyh.groups"/></td>
		<td><html:text property="groups" styleClass="MyTextReadOnly" readonly="true"/>
		</td>
		<td align="center"><bean:message key="F03.groupQty"/></td>
		<td><html:text property="groupQty" styleClass="MyText" style="text-align:right" onchange="javascript:judge();"/></td>
		<td align="center"><bean:message key="F03.beginDate"/></td>
		<td><html:text property="startDate" styleClass="MyTextReadOnly" readonly="true"/>
		</td>
	</tr>
	<tr>
	   <td align="center"><bean:message key="F03.quantity"/></td>
		<td><html:text property="quantity" styleClass="MyTextReadOnly" style="text-align:right" readonly="true"/></td>
		<td align="center"><bean:message key="adyh.remark"/></td>
		<td><html:text property="description" styleClass="MyText"/></td>
		<td align="center"><bean:message key="F03.endDate"/></td>
		<td><html:text property="finishDate" styleClass="MyText" onblur="javascript:initDate();" onclick="return CalendarClick(this)" />
		</td>
	</tr>
	<tr>
		<td align="center"><bean:message key="F0301.purchase"/></td>
		<td><html:select property="purchaseFlag" styleClass="MySelect">
		       <html:option value="0">否</html:option>
		       <html:option value="1">是</html:option> 
		</html:select></td>
		<td align="center">&nbsp;</td>
		<td>&nbsp;</td>
		<td align="center">&nbsp;</td>
		<td>&nbsp;</td>
	</tr>
  </table>
</div>
</div>
<!--End：表单折叠区块1-->
<div class="DivBlock">
<div class="DivButton">
  <input type="button" name="Submit1" class="MyButton" value="<bean:message key="common.save"/>" onClick="javascript:operation1();">
  <input type="button" name="Submit2" class="MyButton" value="<bean:message key="common.back"/>" onClick="javascript:operation('back');">
</div>
</div>
<html:messages id="aa" message="true"><bean:message key="errors.prefix"/><bean:write name="aa"/><bean:message key="errors.suffix"/></html:messages>
</html:form>
</body>
<script language="Javascript1.2" type="text/javascript">

	function validateActionForm(form){ 
		return validateMinLength(form)&&validateMaxLength(form)&&validateRequired(form);
	} 

    function minlength() { 
    	//this.aa = new Array("CODE", "代码 长度应为2位！", new Function ("varName", "this.minlength='2';  return this[varName];"));
    }  

	function maxlength(){
		//this.aa = new Array("CODE", "代码 长度大于10位！", new Function ("varName", "this.maxlength='10';  return this[varName];"));
		//this.bb = new Array("NAME", "名称 长度大于50个汉字！", new Function ("varName", "this.maxlength='100';  return this[varName];"));
		
		//this.dd = new Array("URL", "链接 长度大于400位！", new Function ("varName", "this.maxlength='400';  return this[varName];"));
	}
	
	function required(){
		//this.aa = new Array("CODE", "代码 不能为空！", new Function ("varName", "this.nullable='false';  return this[varName];"));
		//this.bb = new Array("NAME", "工作号 不能为空！", new Function ("varName", "this.nullable='false';  return this[varName];"));
		//this.cc = new Array("PARENTNAME", "上级功能点 不能为空！", new Function ("varName", "this.nullable='false';  return this[varName];"));
		//this.dd = new Array("URL", "链接 不能为空！", new Function ("varName", "this.nullable='false';  return this[varName];"));
	}

</script>
</html:html>